package com.yami.shop.coupon.common.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 优惠券
 * @author lanhai
 */
@Data
@TableName("tz_coupon")
@Schema(description ="优惠券")
public class Coupon implements Serializable {
    private static final long serialVersionUID = 8018312153820119913L;

    @TableId
    @Schema(description = "优惠券id")
    private Long couponId;

    @Schema(description = "店铺ID")
    private Long shopId;

    @Schema(description = "优惠券名称")
    private String couponName;

    @Schema(description = "副标题")
    private String subTitle;

    @Schema(description = "优惠类型 1:代金券 2:折扣券 3:兑换券")
    private Integer couponType;

    @Schema(description = "使用条件")
    private Double cashCondition;

    @Schema(description = "减免金额")
    private Double reduceAmount;

    @Schema(description = "折扣额度")
    private Double couponDiscount;

    @Schema(description = "生效类型 1:固定时间 2:领取后生效")
    private Integer validTimeType;

    @Schema(description = "投放时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date launchTime;

    @Schema(description = "开始时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    @Schema(description = "结束时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;

    @Schema(description = "领券后X天起生效")
    private Integer afterReceiveDays;

    @Schema(description = "有效天数")
    private Integer validDays;

    @Schema(description = "库存")
    private Integer stocks;

    @Schema(description = "原始库存")
    private Integer sourceStock;

    @Schema(description = "适用商品类型 0全部商品参与 1指定商品参与 2指定商品不参与")
    private Integer suitableProdType;

    @Schema(description = "每个用户领券上限，如不填则默认为1")
    private Integer limitNum;

    @Schema(description = "版本号")
    private Integer version;

    @Schema(description = "是否积分优惠券 0不是 1是")
    private Integer isScoreType;

    @Schema(description = "积分价格")
    private Integer scorePrice;

    @Schema(description = "优惠券过期状态 0:过期 1:未过期")
    private Integer overdueStatus;

    @Schema(description = "优惠券投放状态 0:未投放 1:投放 -1取消投放")
    private Integer putonStatus;

    @Schema(description = "优惠商品")
    @TableField(exist = false)
    private List<CouponProd> couponProds;

    @Schema(description = "优惠券所在的店铺")
    @TableField(exist = false)
    private String shopName;

    @Schema(description = "获取方式  0=客户领取 1=平台发放")
    private Integer getWay = 0;

    @Schema(description = "优惠券领取次数")
    @TableField(exist = false)
    private Integer takeNum = 0;

    @Schema(description = "优惠券微商城使用次数")
    @TableField(exist = false)
    private Integer useNum = 0;
}
